package org.xserver.component.exception;

/**
 * Created by bin on 2015-12-28.
 */
public class TokenFilterError extends FilterProcessError {

	public TokenFilterError(String message) {
		super(TokenFilterError.class.getSimpleName(), message);
	}

	public TokenFilterError(String filterName, String message) {
		super(filterName, message);
	}

	public TokenFilterError(String filterName, String errorCode, String errorMessage) {
		super(filterName, "errorCode: " + errorCode + ", errorMessage: " + errorMessage);
		setCode(errorCode);
	}

	public TokenFilterError(TokenFilterErrorEnum tokenFilterErrorEnum) {
		super(TokenFilterError.class.getSimpleName(),
				"errorCode: " + tokenFilterErrorEnum.getCode()
						+ ", errorMessage: " + tokenFilterErrorEnum.getValue());
		setCode(tokenFilterErrorEnum.getCode());
	}

	public enum TokenFilterErrorEnum {
		TOKEN_IS_NULL("10000004", "token is null"),
		TOKEN_OVERDUE("10000005", "token overdue"),
		TOKEN_ERROR("10000006", "token error"),
		TOKEN_SYSTEM_ERROR("10000007", "token system error"),
		PROJECT_NOT_FOUND("10000008", "cannot found project by token"),
		USER_NOT_FOUND("10000009", "cannot found user by token");
		
		private String code;
		private String value;
		TokenFilterErrorEnum(String code, String value) {
			this.code = code;
			this.value = value;
		}

		public String getValue() {
			return value;
		}

		public String getCode() {
			return code;
		}
	}
}
